<template>
   <SlotsAddProjectOpt :loading="loading" :loadingText="loadingText">
       <div class="w-100">
           <!-- 操作区文本框 -->
           <JsonEditor 
               ref="jsonEditorRef" 
               :json="data.dueDiligenceOptRecord.disposalResults"
               :expand="data.jsonexpands" 
           />
           <!-- 操作区按钮组 -->
           <AddProjectOperateButton 
               :opdateButtons="opeateParam.opdateButtons" 
               @warehouseQuery="warehouseQuery" 
               @reIdentifyElement="reIdentifyElement"
               class="d-flex justify-content-end pt-3 pe-3"
           />
       </div>
   </SlotsAddProjectOpt>
</template>

<script setup lang="ts">
    import { ref, reactive, onMounted } from 'vue'
    import { genFileId, ElMessage } from 'element-plus'
    import { useRouter } from "vue-router";
    import AddProjectOperateBox from '/src/components/AddProjectOperateBox.vue'
    import AddProjectOperateButton from '/src/components/AddProjectOperateButton.vue'
    import SlotsAddProjectOpt from '/src/components/SlotsAddProjectOpt.vue'
    import { ResultCheck } from "/src/api/addProject";
    import JsonEditor from '/src/components/JsonEditor.vue'
    import ProjectName from '/src/components/project/ProjectName.vue'
    import { GetRecord,QueryQcc } from '@/api/common/dueDiligenceOptRecord.js'
    import { ReIdentifyElement } from '@/api/common/dueDiligenceProject.js'

    const router = useRouter();
    const loading = ref(false)
    const loadingText = ref('Lodding...')
    const jsonEditorRef = ref(null)

    const opeateParam = reactive({
        opeateText: '识别查询结果，启动仓库查询',
        opdateButtons: [
            { name: '上传修改', methond: 'reIdentifyElement' },
            { name: '数据入库', methond: 'warehouseQuery' }
        ],
    });

    const data = reactive({
        dueDiligenceOptRecord:{
            disposalResults:{}
        }
    })

    /**
     * 初始化方法
     */
    onMounted(() => {
        data.dueDiligenceOptRecord.disposalResults=JSON.parse('{"公告名称":"泉州豪生发展有限公司债权资产转让意向征集公告","公告ID":"8664","公告日期":"2023-07-12","行业":"未提供","债权详情":[{"债务人":"泉州豪生发展有限公司","债权合计金额(万元)":"90633.850389","本金(万元)":"5878.2887699","利息(万元)":"3185.096269","其它费用(万元)":"未提供","诉讼情况":"未提供","债务人所在地":"泉州市","债务人所在省":"福建省","债务人所在市":"泉州市","担保方式":"抵押担保、质押担保、连带保证担保","担保人或保证人":"泉州豪生发展有限公司、张海仙、泉州丰泽日盛发展有限公司","基准日":"2023-06-20","抵质押物":[{"抵质押物详情(包括名称、用途、面积等)":"泉州豪生发展有限公司名下位于泉州洛江中心区的国有建设用地使用权及泉州洛江中心城区C19-02-02地块、C19-02-03地块的泉州国际豪生商住1号楼、商务2号楼、地下室在建工程和土地使用权，张海仙名下持有的泉州豪生发展有限公司51%股权及泉州丰泽日盛发展有限公司名下持有的州豪生发展有限公司49%股权","抵质押物类型":"在建工程、土地使用权、股权","抵质押物地址":"泉州洛江中心区","抵质押物所在省":"福建省","抵质押物所在市":"泉州市"}]}]}')
    })

    /**
     * 启动仓库查询
     */
    const warehouseQuery = () => {
        loadingText.value = '数据正在入库，请稍等...'
        // 开启loading
        loading.value = true;
        setTimeout(() => {
            loading.value = false;
            router.push('/bi_frontend/assetTagging/result')
        }, 5000);
    }
    /**
     * 重新要素识别
     */
    const reIdentifyElement = () => {
        setTimeout(() => {
            ElMessage.success('上传成功')
        }, 200);
    }
</script>



<style scoped>
    .jsoneditor-vue{
	    height: 100%;
	}
</style>